<?php require_once('../connections/con_gl.php'); ?>
<?php
$getquery = str_replace("+"," ",$_GET[query]);
$getquerykorporate = str_replace("+"," ",$_GET[query_korporate]);
mysql_select_db($database_con_gl, $con_gl);
$query_rtrans = stripslashes($getquery);
$rtrans = mysql_query($query_rtrans, $con_gl) or die(mysql_error());
$row_rtrans = mysql_fetch_assoc($rtrans);
$totalRows_rtrans = mysql_num_rows($rtrans);
$mulai = $_GET['mulai'];
$akhir = $_GET['akhir'];    
	
mysql_select_db($database_con_gl, $con_gl);
$query_datakorporate = $getquerykorporate;
$cekdatakorporate= mysql_query($query_datakorporate, $con_gl) or die(mysql_error());
$row_datakorporate = mysql_fetch_assoc($cekdatakorporate);
$totalRows_korporate = mysql_num_rows($cekdatakorporate);

mysql_select_db($database_con_gl, $con_gl);
$query_data = $getquery;
$cekdata= mysql_query($query_data, $con_gl) or die(mysql_error());
$row_data = mysql_fetch_assoc($cekdata);
$totalRows_cekbrg = mysql_num_rows($cekdata);

mysql_select_db($database_con_gl, $con_gl);
$query_getcompany = "SELECT * FROM gl_company WHERE id = 1";
$getcompany = mysql_query($query_getcompany, $con_gl) or die(mysql_error());
$row_getcompany = mysql_fetch_assoc($getcompany);
$totalRows_getcompany = mysql_num_rows($getcompany);
?>
<style type="text/css">
<!--
.style2 {font-size: 18px}
-->
</style>

<P align="center"><span class="style2"><strong>CIPAGANTI RENTAL CAR & TRAVEL</strong></span></P>
<P align="center" class="style2"><strong>PENERIMAAN HASIL SEWA KENDARAAN</strong></P>
<br />
<p align="left"></P>
<p align="left">&nbsp;</P>
<table width="100%" border="0" cellpadding="4" cellspacing="0" bordercolor="#000000">
<tr>
</tr>
 <th width="200">CABANG : <?php echo $row_data['gudang']; ?></th>
   <th width="78">&nbsp;</th>
    <th width="100">&nbsp;</th>
	<th width="80">&nbsp;</th>
	<th width="300">&nbsp;</th>
	<th width="100">&nbsp;</th>
	<th width="100">&nbsp;</th>
	<th width="250">&nbsp; </th>    
    <th width="100" align="center"></th>
    <th width="100" align="center"></th>
    <th width="100" align="center">PERIODE : <?php echo $mulai.'-'.$akhir ?></th>
</table>
<table width="100%" border="1" cellpadding="4" cellspacing="0" bordercolor="#000000">
    <tr bgcolor="#CCCCCC">
      <th width="200">User</th>
      <th width="200">Customer </th>
   <th width="78"><strong>Berangkat</strong></th>
    <th width="100"><strong>No Invoice</strong></th>
	<th width="78">No. Kendaraan</th>
	<th width="78">Periode Awal</th>
	<th width="78">Periode Akhir</th>
	<th width="100" align="center"><strong>Angsuran</strong></th>
    <th width="100" align="center"><strong>Uang Muka</strong></th>
    <th width="100" align="center"><strong>Jaminan</strong></th>
    <th width="100" align="center">Denda</th>
    <th width="100" align="center">Tunai</th>
    <th width="100" align="center">CQ/BG/CD</th>
    <th width="100" align="center">Operasional</th>
    <th width="100" align="center">Total</th>
    </tr>
	
	


        <tr valign="top">
          <td colspan="15" align="left"><strong>SEWA KENDARAAN RETAIL</strong></td>
        </tr>
        <?php do { ?>
        <tr valign="top">
          <td align="left"><?php echo $row_data['user'];?></td>
          <td align="left"><?php echo $row_data['customer'];?></td>
          <td align="left"><?php echo $row_data['checkin'];?></td>
          <td align="left"><?php echo $row_data['no_ref']; ?></td>
          <td align="left" ><?php echo $row_data['kendaraan']; ?></td>
          <td align="left"><?php echo $row_data['periodeawal']; ?></td>
          <td align="left"><?php echo $row_data['periodeakhir']; ?></td>
          <td align="right"><?php echo number_format($row_data['angsuran'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo number_format($row_data['uangmuka'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo "0"; ?></td>
          <td align="right"><?php echo "0"; ?></td>
          <td align="right"><?php echo number_format($row_data['tunai'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo number_format($row_data['transfer'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo number_format($row_data['operasional'],0,',','.').",-"; ?></td>
          <td align="right"><?php echo number_format($row_data['total'],0,',','.').",-"; ?></td>
        </tr>
			<?php 
          $totalangsuran += $row_data['angsuran'];
          $totaluangmuka += $row_data['uangmuka'];
		  $totaltrasfer += $row_data['transfer'];
          $totaltunai += $row_data['tunai'];
          $totaloperasional += $row_data['operasional'];
		  $total += $row_data['total'];
        } while ($row_data = mysql_fetch_assoc($cekdata)); ?>
        <tr valign="top">
          <td colspan="7" align="center"><span style="font-weight: bold">SUB TOTAL :</span></td>
          <td align="right"><?php echo number_format($totalangsuran,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format($totaluangmuka,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format(0,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format(0,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format($totaltunai,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format($totaltransfer,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format($totaloperasional,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format($total,0,',','.').",-";?></td>
        </tr>
        
        <tr valign="top">
          <td colspan="15" align="left"><strong>SEWA KENDARAAN NON RETAIL (Corporate)</strong></td>
        </tr>
        <?php do { ?>
    <tr valign="top">
      <td align="left"><?php echo $row_datakorporate['user'];?></td>
      <td align="left"><?php echo $row_datakorporate['customer'];?></td>
	  <td height="47" align="left"><?php echo $row_datakorporate['checkin']; ?></td>
      <td align="left"></a><?php echo $row_datakorporate['no_ref']; ?></td>
      <td><?php echo $row_datakorporate['kendaraan']; ?></td>
      <td><?php echo $row_datakorporate['periodeawal']; ?></td>
      <td><?php echo $row_datakorporate['periodeakhir']; ?></td>
      <td align="right"><?php echo number_format($row_datakorporate['angsuran'],0,',','.').",-"; ?></td>
      <td align="right"><?php echo number_format($row_datakorporate['uangmuka'],0,',','.').",-"; ?></td>
      <td align="right"><?php echo "0";?></td>
      <td align="right"><?php echo "0";?></td>
      <td align="right"><?php echo number_format($row_datakorporate['tunai'],0,',','.').",-"; ?></td>
      <td align="right"><?php echo number_format($row_datakorporate['transfer'],0,',','.').",-"; ?></td>
      <td align="right"><?php echo number_format($row_datakorporate['operasional'],0,',','.').",-"; ?></td>
      <td align="right"><?php echo number_format($row_datakorporate['total'],0,',','.').",-";?></td>
    </tr>
	<?php 
          $totalangsurankorporate += $row_datakorporate['angsuran'];
          $totaluangmukakorporate += $row_datakorporate['uangmuka'];
		  $totaltrasferkorporate += $row_datakorporate['transfer'];
          $totaltunaikorporate += $row_datakorporate['tunai'];
          $totaloperasionalkorporate += $row_datakorporate['operasional'];
		  $totalkorporate += $row_datakorporate['total'];
        } while ($row_datakorporate = mysql_fetch_assoc($cekdatakorporate)); ?>
    <tr valign="top">
      <td colspan="7" align="center"><strong>SUBTOTAL</strong></td>
      <td align="right"><strong><?php echo number_format($totalangsurankorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totaluangmukakorporate,0,',','.').",-";?></strong></td>
      <td align="right"><?php echo "0";?></td>
      <td align="right"><?php echo "0";?></td>
      <td align="right"><strong><?php echo number_format($totaltunaikorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totaltrasferkorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totaloperasionalkorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totalkorporate,0,',','.').",-";?></strong></td>
  </tr>
    <tr valign="top">
      <td colspan="7" align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
</tr>
    <tr valign="top">
      <td colspan="7" align="center"><strong>GRAND TOTAL</strong></td>
      <td align="right"><strong><?php echo number_format($totalangsuran+$totalangsurankorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totaluangmuka+$totaluangmukakorporate,0,',','.').",-";?></strong></td>
      <td align="right">&nbsp;</td>
      <td align="right">&nbsp;</td>
      <td align="right"><strong><?php echo number_format($totaltunai+$totaltunaikorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totaltransfer+$totaltransferkorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($totaloperasional+$totaloperasionalkorporate,0,',','.').",-";?></strong></td>
      <td align="right"><strong><?php echo number_format($total+$totalkorporate,0,',','.').",-";?></strong></td>
  </tr>
</table>
  
  
